#!/bin/bash

IFS=$'\n'

for fileName in `find . ! -name . -prune -type f` 
do

	day=`date --utc --reference="${fileName}" +%d`
	month=`date --utc --reference="${fileName}" +%m`
	year=`date --utc --reference="${fileName}" +%Y`

	echo "fileName=${fileName} dzien=${day} miesiac=${month} rok=${year}"
	
	dirName=${year}${month}${day}

	if [ -d $dirName ]; then
		echo "katalog jest"
	else
		echo "katalogu nie ma"
		mkdir ${dirName}
	fi

	mv ${fileName} ./${dirName}

done
